<?

class osWirelessAccessPoint extends osGeneric {
	public $id = 'adsl';
	public $tabs = array(
		'interfaces'=>'Interfaces'
	);
	
	public function getResources() {
	
		// Operating System Information
		
		
		// Device Information
		foreach ($this->device->snmp->find('HOST-RESOURCES-MIB','hrDeviceIndex') AS $key=>$index) {
			$item = $this->device->snmp->find('HOST-RESOURCES-MIB','hrDevice([a-zA-z0-9]+).'.$index,true);
			$item = $item[$index];
			switch (substr($item['hrDeviceType'],strrpos(':',$item['hrDeviceType']))) {
				case 'hrDeviceProcessor':
					$this->cpus[]  = new objProcessor($item);
					break;
				case 'hrDeviceNetwork':
					$this->device->interfaces[] = new objInterface($item);
			}
		
		
		}
		
		// Storage/Memory Information
		foreach ($this->device->snmp->find('HOST-RESOURCES-MIB','hrStorageIndex') AS $key=>$index) {
			$item = $this->device->snmp->find('HOST-RESOURCES-MIB','hrStorage([a-zA-z0-9]+).'.$index,true);
			$item = $item[$index];
			switch (substr($item['hrStorageType'],strrpos(':',$item['hrStorageType']))) {
				case 'hrStorageRam':
					$this->device->ram = $item['hrStorageSize']*substr($item['hrStorageAllocationUnits'],0,strpos(' ',$item['hrStorageAllocationUnits']));
				case 'hrStorageVirtualMemory':
					$this->memory[$index] = new objMemory($item);
					break;
				case 'hrStorageFixedDisk':
					$this->storage[$index] = new objStorage($item);
					break;
					
			}
		}
	
		// Interfaces Information
		foreach ($this->device->snmp->find('IF-MIB','ifIndex') AS $key=>$index) {
			$item = $this->device->snmp->find('IF-MIB','if([a-zA-z0-9]+).'.$index,true);
			$item = $item[$index];
			$item['device_id'] = $this->device->id;
			$this->device->interfaces[$index] = new objInterface($item);
		}
	
	
	
	}
	
	public function checkDescription($sysDescr='') { 
		return preg_match("/^Apple AirPort/", $sysDescr)?$this->id:'';
	}
	public function getType() { 
		$sysDescr = $this->device->snmp->get('SNMPv2-MIB','sysDescr.0');
		if (preg_match("/AirPort/", $sysDescr)) {
			return $this->device->os_type.'_apple_airport';
		} else return $this->device->os_type;
	}
	public function getDescription() { 
		$sysDescr = $this->device->snmp->get('SNMPv2-MIB','sysDescr.0');
		if (preg_match("/AirPort/", $sysDescr)) {
		 	$output = array();
		 	foreach (explode('-',$sysDescr) AS $part) {
		 		$output[] = trim($part); 
		 	}
		 	return implode('<br/>',$output);
		 } else return $sysDescr;
	}
	public function getUptime() { 
		return $this->device->snmp->get('DISMAN-EVENT-MIB','sysUpTimeInstance');
	}
}


?>